﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using devtm.AutoMapper.TemplateAdd;

namespace devtm.AutoMapper.CustomCode.TemplateAdd
{
    /// <summary>
    /// Interaction logic for TypeSelector.xaml
    /// </summary>
    public partial class TypeSelector : UserControl
    {




        public TypeSelector()
        {

            InitializeComponent();
            
        }


        public ItemCollection Items
        {
            get
            {
                return treeView1.Items;
            }
        }


        internal void Select(AutoMapper.TemplateAdd.Models.TypeBox typeBox)
        {

            SelectedItem = typeBox.Type;
            SelectedNamespace = null;

            if (Selected != null)
                Selected(typeBox, new SelectedEventArgs(SelectedItem));
        }

        internal void Select(AutoMapper.TemplateAdd.Models.NamespaceBox @namespace)
        {
            SelectedItem = null;
            SelectedNamespace = @namespace.Namespace;

            if (Selected != null)
                Selected(@namespace, new SelectedEventArgs(@namespace.Namespace));
        }

        internal void Select(AutoMapper.TemplateAdd.Models.AssemblyBox assemblyBox)
        {

            SelectedItem = null;
            SelectedNamespace = null;

            if (Selected != null)
                Selected(assemblyBox, new SelectedEventArgs());
        }

        public event EventHandler<SelectedEventArgs> Selected;


        public Mono.Cecil.TypeDefinition SelectedItem { get; set; }
        public string SelectedNamespace { get; set; }
        
    }
}
